﻿using System.Threading;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using IQIGame.Onigao.Framework;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class StoryAction_Scale : StoryAction
    {
        private float _scale;

        protected override bool OnInitialize(GameObject root, StoryActionData data)
        {
            base.OnInitialize(root, data);
            if (data is StoryActionData_Scale rScale)
            {
                this._scale = rScale.scale;
                return true;
            }
            return false;
        }

        protected override async UniTask OnStart(CancellationToken cancel)
        {
            await base.OnStart(cancel);
            this.root.transform.localScale = Vector3.one * this._scale;
        }


        public override void OnReset()
        {
            base.OnReset();
            this._scale = 0;
        }

        public override void Free()
        {
            ClassPool.Put(this);
        }
    }
}